package com.tengju.bff.interfaces.covercharge.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tengju.bff.interfaces.covercharge.constant.ServiceWithdrawCycleAddCheckLogEnum;
import com.tengju.bff.interfaces.covercharge.entity.po.ServiceWithdrawCycleAddCheckLog;
import com.tengju.bff.interfaces.covercharge.mapper.ServiceWithdrawCycleAddCheckLogMapper;
import com.tengju.bff.interfaces.covercharge.service.IServiceWithdrawCycleAddCheckLogService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author wangcheng
 * @date 2020/10/23
 * @description 1.0
 */
@Service
@Slf4j
public class ServiceWithdrawCycleAddCheckLogServiceImpl extends ServiceImpl<ServiceWithdrawCycleAddCheckLogMapper, ServiceWithdrawCycleAddCheckLog> implements IServiceWithdrawCycleAddCheckLogService {
    /**
     * 获取数据校验
     * @param startAt 周期开始时间
     * @param endAt 周期结束时间
     * @return
     */
    @Override
    public Boolean getCheckLogInfo(String startAt,String endAt){
        Boolean isTrue=false;
        QueryWrapper<ServiceWithdrawCycleAddCheckLog> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("start_at", startAt);
        queryWrapper.eq( "end_at", endAt);
        queryWrapper.orderByDesc("id");
        queryWrapper.last("limit 1");
        ServiceWithdrawCycleAddCheckLog checkLog=this.getOne(queryWrapper);
        if(checkLog!=null && checkLog.getStatus().equals(ServiceWithdrawCycleAddCheckLogEnum.NORMAL.getCode())){
            isTrue=true;
        }
        return isTrue;
    }
}
